﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;

public partial class UserControl_DanhSachTinRaoVat : System.Web.UI.UserControl
{
    private int maDanhMucCon = -1;

    public int MaDanhMucCon
    {
        get { return maDanhMucCon; }
        set { maDanhMucCon = value;
        DuaDuLieuVaoBang();
        }
    }
    private bool layTinHot = true;

    public bool LayTinHot
    {
        get { return layTinHot; }
        set { DanhSachTinRaoVatTheoList1.LayTinHot = value; }
    }

    private bool layTinThuong = true;

    public bool LayTinThuong
    {
        get { return layTinThuong; }
        set { DanhSachTinRaoVatTheoList1.LayTinThuong = value; }
    }

    private int widthGridView = 750;

    public int WidthGridView
    {
        get { return widthGridView; }
        set { widthGridView = value;
       
          DanhSachTinRaoVatTheoList1.WidthGridView = value;
        }
    }

    private bool showFooter;

    public bool ShowFooter
    {
        get { return showFooter; }
        set
        {
            showFooter = value;
              DanhSachTinRaoVatTheoList1.ShowFooter =  value;
        }
    }

   
    private bool showHeader = true;

    public bool ShowHeader
    {
        get { return showHeader; }
        set
        {
            showHeader = value;
              DanhSachTinRaoVatTheoList1.ShowHeader = value;
        }
    }

    private bool showBtnDangBaiRaoVat;

    public bool ShowBtnDangBaiRaoVat
    {
        get { return showBtnDangBaiRaoVat; }
        set
        {
            showBtnDangBaiRaoVat = value;
            DanhSachTinRaoVatTheoList1.ShowBtnDangBaiRaoVat = value;
        }
    }

    private bool showGridViewHeader = true;

    public bool ShowGridViewHeader
    {
        get { return showHeader; }
        set
        {
            showGridViewHeader = value;
              DanhSachTinRaoVatTheoList1.ShowGridViewHeader = value;
        }
    }

    private string ten;

    public string Ten
    {
        get { return ten; }
        set
        {
            ten = value;
            DanhSachTinRaoVatTheoList1.Ten = value;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
      
      
    }

    public void DuaDuLieuVaoBang()
    {
        LinQ_RaoVatDataContext linQ = new LinQ_RaoVatDataContext();


        var query = from TinRaoVat in linQ.TIN_RAO_VATs where TinRaoVat.MaDanhMucCon == maDanhMucCon && TinRaoVat.Deleted == false && TinRaoVat.ViPham == false orderby TinRaoVat.ThoiGianDang descending select TinRaoVat;
        var KiemTraDanhMucCon = from DanhMucCon in linQ.DANH_MUC_CONs
                                where DanhMucCon.MaDanhMucCon == maDanhMucCon && DanhMucCon.Deleted == false 
                                select DanhMucCon;
        if (KiemTraDanhMucCon.Count() == 0)
        {
            DanhSachTinRaoVatTheoList1.ListTinRaoVat = null;
        }
        else
        {
            DanhSachTinRaoVatTheoList1.ListTinRaoVat = query.ToList();
           
           
        }
    }
 
}
